import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class CheckBoxDemo(QWidget):
    def __init__(self,parent=None):
        super(CheckBoxDemo,self).__init__(parent)
        groupbox=QGroupBox("Checkboxes")
        groupbox.setFlat(False)
        layout=QHBoxLayout()
        self.checkBox1=QCheckBox("checkBox1")
        self.checkBox1.setChecked(True)
        self.checkBox1.stateChanged.connect(lambda:self.btnstate(self.checkBox1))

        layout.addWidget(self.checkBox1)
        groupbox.setLayout(layout)
        mainlayout=QVBoxLayout()
        mainlayout.addWidget(groupbox)
        self.setLayout(mainlayout)
        self.setWindowTitle("checkbox demo")
    def btnstate(self,btn):
        print(str(self.checkBox1.isChecked()))
        print(self.checkBox1.text())
        print(btn.text())
         
if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=CheckBoxDemo()
    win.show()
    sys.exit(app.exec_())